﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TasteItem.cs" company="Simon Carpentier">
//   Microsoft Reciprocal License (Ms-RL)
// </copyright>
// <summary>
//   Defines the Taste type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace VinoCellar.Model
{
    using System;
    using System.ComponentModel;
    using System.Data.Linq;
    using System.Data.Linq.Mapping;

    /// <summary>
    /// Représente une dégustation de vin dans le modèle du domaine
    /// </summary>
    [Table]
    public class TasteItem : INotifyPropertyChanged, INotifyPropertyChanging
    {
        /// <summary>
        /// Version de l'enregistrement
        /// </summary>
        /// <remarks>Version column aids update performance.</remarks>
        [Column(IsVersion = true)]
        private Binary version;

        /// <summary>
        /// Event that fires when a property has changed
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Event that fires when a property is about to change
        /// </summary>
        public event PropertyChangingEventHandler PropertyChanging;

        /// <summary>
        /// Used to notify that a property changed
        /// </summary>
        /// <param name="propertyName">Name of the property that changed</param>
        private void NotifyPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        /// <summary>
        /// Used to notify that a property is about to change
        /// </summary>
        /// <param name="propertyName">Name of the property that is about to change</param>
        private void NotifyPropertyChanging(string propertyName)
        {
            if (this.PropertyChanging != null)
            {
                this.PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
            }
        }

        private int tasteItemId;

        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int TasteItemId
        {
            get { return this.tasteItemId; }
            set
            {
                if (this.tasteItemId != value)
                {
                    this.NotifyPropertyChanging("TasteItemId");
                    this.tasteItemId = value;
                    this.NotifyPropertyChanged("TasteItemId");
                }
            }
        }

        private int wineItemId;

        [Column(DbType = "INT NOT NULL", CanBeNull = false)]
        public int WineItemId
        {
            get { return this.wineItemId; }
            set
            {
                if (this.wineItemId != value)
                {
                    this.NotifyPropertyChanging("WineItemId");
                    this.wineItemId = value;
                    this.NotifyPropertyChanged("WineItemId");
                }
            }
        }

        private float tasteLocationLat;

        [Column]
        public float TasteLocationLat
        {
            get { return this.tasteLocationLat; }
            set
            {
                if (this.tasteLocationLat != value)
                {
                    this.NotifyPropertyChanging("tasteLocationLat");
                    this.tasteLocationLat = value;
                    this.NotifyPropertyChanged("tasteLocationLat");
                }
            }
        }

        private float tasteLocationLon;

        [Column]
        public float TasteLocationLon
        {
            get { return this.tasteLocationLon; }
            set
            {
                if (this.tasteLocationLon != value)
                {
                    this.NotifyPropertyChanging("tasteLocationLon");
                    this.tasteLocationLon = value;
                    this.NotifyPropertyChanged("tasteLocationLon");
                }
            }
        }

        private string tasteNotes;

        [Column]
        public string TasteNotes
        {
            get { return this.tasteNotes; }
            set
            {
                if (this.tasteNotes != value)
                {
                    this.NotifyPropertyChanging("tasteNotes");
                    this.tasteNotes = value;
                    this.NotifyPropertyChanged("tasteNotes");
                }
            }
        }

        private int tasteScore;

        [Column]
        public int TasteScore
        {
            get { return this.tasteScore; }
            set
            {
                if (this.tasteScore != value)
                {
                    this.NotifyPropertyChanging("TasteScore");
                    this.tasteScore = value;
                    this.NotifyPropertyChanged("TasteScore");
                }
            }
        }

        private DateTime tasteDate;

        [Column]
        public DateTime TasteDate
        {
            get { return this.tasteDate; }
            set
            {
                if (this.tasteDate != value)
                {
                    this.NotifyPropertyChanging("TasteDate");
                    this.tasteDate = value;
                    this.NotifyPropertyChanged("TasteDate");
                }
            }
        }
    }
}
